﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TsTreeTimeSeries.node
{
    class tsObject
    {
        #region

        public List<char> tsInfo; // danh sach thong tin 
        public List<float> tsValue; // danh sach so thuc sau khi thu giam chieu
        public List<float> tsValueO; // danh sach so thuc ban dau
      
        #endregion

        public tsObject()
        {
            tsValueO = new List<float>();
        }

        public tsObject(List<char> tsInfo)
        {
            this.tsInfo = tsInfo;
        }

        public void Quantization(int max, int min, char[] symbols)
        {
            tsInfo = new List<char>();
            int k = (max - min) / symbols.Length;
            for (int i = 0; i < tsValue.Count; i++)
            {
                for (int j = 0; j < symbols.Length; j++)
                {
                    if (tsValue[i] >= min + k * j && tsValue[i] <= min + k * (j + 1)) { tsInfo.Add(symbols[j]); break; }
                }

            }
        }

        public void PAA(int reductionRatio)
        {
            tsValue = new List<float>();
            for (int i = 0; i < tsValueO.Count; i += reductionRatio)
            {
                float temp = 0;
                for (int j = 0; j < reductionRatio; j++)
                {
                    temp += tsValueO[i + j];
                }
                tsValue.Add((float)temp / reductionRatio);
            }
        }

        public tsObject copy()
        {
            return new tsObject(this.tsInfo);
        }


    }
}
